package org.linlinjava.litemall.admin.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.admin.service.AdminOrderService;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallOrderCommission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by 75720 on 2019/05/17.
 */
@RestController
@RequestMapping("/admin/distribution")
@Validated
@Api("分销管理")
public class AdminDistributionController {
    private final Log logger = LogFactory.getLog(AdminOrderController.class);

    @Autowired
    private AdminOrderService adminOrderService;


    @RequiresPermissions("admin:distribution:commission")
    @RequiresPermissionsDesc(menu = {"分销管理", "订单提成"}, button = "详情")
    @ApiOperation(value = "订单提成", httpMethod = "POST")
    @PostMapping("/commissionlist")
    public Object queryOrderCommission(@RequestBody LitemallOrderCommission orderCommission,
                                       @RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer limit,
                                       @Sort @RequestParam(defaultValue = "created_time") String sort,
                                       @Order @RequestParam(defaultValue = "desc") String order) {
        return adminOrderService.queryOrderCommissionList(orderCommission.getUserId(), orderCommission.getUsername(), orderCommission.getRecommenderId(),
                orderCommission.getRecommendername(), orderCommission.getOrderId(), orderCommission.getOrderSn(), page, limit, sort, order);
    }

}
